package com.wk.code.wkserver.controller.app;


import com.wk.code.wkserver.controller.common.BaseController;
import com.wk.code.wkserver.request.app.UserInfoRequest;
import com.wk.code.wkserver.response.app.UserInfoDetailResponse;
import com.wk.code.wkserver.response.result.R;
import com.wk.code.wkserver.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * User 控制层
 *
 * @Author wq
 * @Date 2021-03-16
 **/
@RestController
@RequestMapping("/userInfo")
@AllArgsConstructor
@Api(tags = "app-前台用户基本信息管理")
public class UserInfoController extends BaseController {

    private final IUserInfoService userInfoService;

    /**
     * 更新用户基本信息
     *
     * @param request 请求参数
     * @return R<Void>
     */
    @ApiOperation(value = "更新用户基本信息")
    @PostMapping("/update")
    public R<Void> updateUserInfo(@RequestBody UserInfoRequest request) {
        userInfoService.updateUserInfo(getUserId(), request);
        return R.success();
    }


    /**
     * 个人资料
     *
     * @return R<UserInfoDetailResponse>
     */
    @ApiOperation(value = "个人资料基本信息")
    @GetMapping("/detail")
    public R<UserInfoDetailResponse> detailUserInfo() {
        return R.success(userInfoService.detail(getUserId()));
    }


    /**
     * 申请成为技术
     *
     * @param request 请求参数
     * @return R<Void>
     */
    @ApiOperation(value = "申请成为技术")
    @PostMapping("/applyTechUser")
    public R<Void> applyTechUser(@RequestBody UserInfoRequest request) {
        userInfoService.applyTechUser(getUserId(), request);
        return R.success();
    }


}